package impl

type QuantAccountServiceImpl struct {
	*BaseServiceImpl
}

func GetQuantAccountServiceImpl() *QuantAccountServiceImpl {
	return &QuantAccountServiceImpl{GetBaseServiceImpl()}
}

// 将quant_*开头的表，恢复为这一天的上一天的数据
func (_quantAccountServiceImpl *QuantAccountServiceImpl) RestoreQuant(date string) {
	// 恢复quant_account表中上一轮的数据
	var previousDate *string = _quantAccountServiceImpl._stockTransactionDataAllDaoImpl.FindLastDateByDate(date)
	_quantAccountServiceImpl._quantAccountDaoImpl.TruncateTable()
	_quantAccountServiceImpl._quantAccountDaoImpl.InsertFromQuantAccountLogByDate(*previousDate)

	// 恢复quant_account_log表中上一轮的数据
	_quantAccountServiceImpl._quantAccountLogDaoImpl.DeleteByDate(date)

	// 恢复quant_stock_transact_record表中上一轮的数据
	_quantAccountServiceImpl._quantStockTransactionRecordDaoImpl.DeleteBySellDateNullAndBuyDate(date)
	_quantAccountServiceImpl._quantStockTransactionRecordDaoImpl.UpdateNullBySellDate(date)
}
